<?php
	function __autoload ($Class) {
		preg_match ('( ^ [a-zA-Z_\x7f-\xff] [a-zA-Z0-9_\x7f-\xff]* $ )x', $Class) or die ('invalid class name');
		list ($Path, $Name) = array ('classes', 'class');
		if ('mod' === substr ($Class, 0, 3)) {list ($Path, $Name) = array ('modules', 'module');}
		if ('if' === substr ($Class, 0, 2)) {list ($Path, $Name) = array ('interfaces', 'interface');}
		file_exists ($FName = "FLCL5/$Path/$Class.php") or die ("$Name $Class not found");
		require_once ($FName);
	}
	foreach (glob ('FLCL5/local/*.php') as $FName) require_once ($FName);
	if (count ($_POST) or count ($_FILES)) {
		$Modules = array ();
		foreach ($_FILES as $K => $V) if (class_exists ($K) and is_callable ($K, 'Process')) foreach ($V as $Part => $Files) foreach ($Files as $FileName => $FileData) $Modules [$K]['Files'][$FileName][$Part] = $FileData;
		foreach ($_POST as $K => $V) is_array ($V) and class_exists ($K) and is_callable ($K, 'Process') and $Modules [$K]['Args'] = $V;
		foreach ($Modules as $ModuleName => $Module) {
			foreach (array ('Files', 'Args') as $V) {
				isset ($Module [$V]) or $Module [$V] = array ();
				is_array ($Module [$V]) or $Module [$V] = array ($Module [$V]);
			}
			is_callable ($ModuleName, 'Process') and call_user_func (array ($ModuleName, 'Process'), $Module ['Args'], $Module ['Files']);
		}
		HTTP::Relocate ();
	}
?>